Back to course home
0% completed
Vote For New Content
Google Hard
Shortest Subarray with Sum at Least K (hard)
Solution: Shortest Subarray with Sum at Least K
Reverse Pairs (hard)
Solution: Reverse Pairs
Nth Magical Number (hard)
Solution: Nth Magical Number
Candy (hard)
Solution: Candy
Arithmetic Slices II - Subsequence (hard)
Solution: Arithmetic Slices II - Subsequence
Burst Balloons (hard)
Solution: Burst Balloons
Sum of Distances in Tree (hard)
Solution: Sum of Distances in Tree
Maximum Score of a Good Subarray (hard)
Solution: Maximum Score of a Good Subarray
Trapping Rain Water (hard)
Solution: Trapping Rain Water
First Missing Positive (hard)
Solution: First Missing Positive
Single Number II (medium)
Problem Statement
Given an array of integers nums where each element appears three times, and one element appears exactly once, return the single element.
Note: You must solve the problem with linear runtime complexity and use only constant extra space.
Examples
- Example 1:
- Input: nums =
[4, 3, 3, 3] - Expected Output:
4 - Justification:
4is the only number that appears once, while3appears three times.
- Input: nums =
- Example 2:
- Input: nums =
[99, 1, 99, 99, 2, 2, 2] - Expected Output:
1 - Justification:
1appears exactly once whereas99and2each appear three times.
- Input: nums =
- Example 3:
- Input: nums =
[0, 7, 2, 7, 2, 7, -1, 2, -1, -1] - Expected Output:
0 - Justification:
0is the unique number appearing once, while7,2and-1appear three times.
- Input: nums =
Try it yourself
Try solving this question here:
Java
Saved to Cloud
. . . .
Solution: Count Unreachable Pairs of Nodes in an Undirected Graph
Solution: Single Number II
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself